**************************************************
*Do-file:
*It's the robots, stupid? Automation Risk, Labour Market Resources and Incumbent Support in Europe
*Research and Politics
*Analysis file

*Janaury 11th 2024*

**************************************************
**************************************************
*******************A. Preamble********************
**************************************************
**************************************************

/*cd "set working directory"*/

use "Final.dta", clear



*/Summary statistics
drop if age > 110

sutex incumbent computerisation realgrowthrate2 eduyrs2 income2 age male urban rlgdgr Contract iorgact regexp Cruderateofnetmigration Unemployment1574  sh_highrisk polintr occf14b imbgeco, lab nobs key(descstat) replace file(descstat.tex) title("Summary statistics") minmax



**************************************************
**************************************************
*******************1. BASELINE********************
**************************************************
**************************************************
*/ In this step we establish the baseline story
*/ To do so I fit two models with individual level controls, one FE and another ME
*/1.1 Logistic fixed effects - regional dummies
eststo clear
eststo: qui asdoc logistic incumbent c.computerisation i.year i.electiondum i.region if  mainsample ==1 [pw=dweight], vce(robust) nest replace 
eststo: qui asdoc logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)  nest append

margins

*/1.2 Mixed effects logistic regression 
eststo: qui asdoc melogit incumbent c.computerisation i.year if  mainsample ==1 [pw=dweight] ||electiondum: ||region:, vce(robust) nest append

eststo: qui asdoc melogit incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year if  mainsample ==1 [pw=dweight] ||electiondum: ||region:, vce(robust) append
  outreg2 using myreg.doc,  keep(computerisation eduyrs2 income2 age male urban rlgdgr) append


esttab  est1  est3 est2  est4, drop(*region *electiondum *year) replace se  s(year electiondum region n, label("Wave FE" "Election FE" "Region FE" "N" )) asdoc replay, nest


*/1.3 Marginsplot
qui logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)

margins,  atmeans at(computerisation=(0(0.2)1))
marginsplot, recast(line) plotopts(lwidth(medthick)) recastci(rline) ciopts(lpattern(dash))  

  
  
**************************************************
**************************************************
*******************2. Regional********************
**************************************************
**************************************************
eststo clear
*/Regional robot exposure
eststo:  qui asdoc logistic incumbent c.computerisation##c.regexp eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum if mainsample==1 [pw=dweight], vce(robust) nest replace 

*/Migration rate
eststo:  qui asdoc logistic incumbent c.computerisation##c.Cruderateofnetmigration eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum if mainsample==1 [pw=dweight], vce(robust) nest append  

*/Unemployment1574
eststo: qui asdoc logistic incumbent c.computerisation##c.Unemployment1574 eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum if mainsample==1 [pw=dweight], vce(robust) nest append  

*/growth rate
eststo: qui asdoc logistic incumbent c.computerisation##c.realgrowthrate2 eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum   if mainsample ==1 [pw=dweight], vce(robust) nest append 

esttab  est1 est2 est3  est4, drop( *electiondum *year) replace se obslast  s(year electiondum region n, label("Wave FE" "Election FE" "Region FE" "N" ))

asdoc replay, nest

**************************************************
**************************************************
*******************2. Interaction*****************
**************************************************
**************************************************
eststo clear

*/Contract
{
eststo: qui asdoc logistic incumbent c.computerisation##i.Contract eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest replace 
margins, atmeans at(Contract=(0 1) computerisation=(0)) post  
eststo m1

eststo: qui logistic incumbent c.computerisation##i.Contract eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)
margins, atmeans at(Contract=(0 1) computerisation=(1)) post    
eststo m2

}

coefplot m1 m2

*/Co-determination
{
eststo: qui asdoc logistic incumbent c.computerisation##c.iorgact eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest append  
margins, atmeans at(iorgact=(1 8) computerisation=(0)) post   
eststo m3

eststo: qui logistic incumbent c.computerisation##c.iorgact eduyrs2  income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)
margins, atmeans at(iorgact=(1 8) computerisation=(1)) post
eststo m4
}

coefplot m3 m4

*/Education
{
eststo: qui asdoc logistic incumbent c.computerisation##c.eduyrs2  income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest append 
margins, atmeans at(eduyrs2=(8 17) computerisation=(0)) post 
eststo m5

eststo: qui logistic incumbent c.computerisation##c.eduyrs2  income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)
margins, atmeans at(eduyrs2=(8 17) computerisation=(1)) post
eststo m6

}
coefplot m5 m6

eststo clear 
eststo: qui asdoc logistic incumbent c.computerisation##i.Contract eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest replace 
eststo: qui asdoc logistic incumbent c.computerisation##c.iorgact eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest append  
eststo: qui asdoc logistic incumbent c.computerisation##c.eduyrs2  income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest append 

asdoc replay, nest

coefplot m5 m6


esttab  est1 est2 est3, drop(*region *electiondum *year ) replace se obslast  s(year electiondum region n, label("Wave FE" "Election FE" "Region FE" "N" ))


*/by model


*high risk
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(1) computerisation=(0.9)) post
eststo m7
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(2) computerisation=(0.9)) post
eststo m8
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(3) computerisation=(0.9)) post
eststo m9
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(4) computerisation=(0.9)) post
eststo m10
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(5) computerisation=(0.9)) post
eststo m11
coefplot m7 m8 m9 m10 m11



eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.wwf if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(wwf=(1) computerisation=(0.9)) post
eststo m12
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.wwf if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(wwf=(2) computerisation=(0.9)) post
eststo m13
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.wwf if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(wwf=(3) computerisation=(0.9)) post
eststo m14
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.wwf if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(wwf=(4) computerisation=(0.9)) post
eststo m15

coefplot m12 m13 m14 m15 



eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(1) computerisation=(0.9)) post
eststo m16
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(2) computerisation=(0.9)) post
eststo m17
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(3) computerisation=(0.9)) post
eststo m18
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(4) computerisation=(0.9)) post
eststo m19
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(5) computerisation=(0.9)) post
eststo m20
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(1) computerisation=(0.1)) post
eststo m21
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(2) computerisation=(0.1)) post
eststo m22
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(3) computerisation=(0.1)) post
eststo m23
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(4) computerisation=(0.1)) post
eststo m24
eststo:  logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.model if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
margins, atmeans at(model=(5) computerisation=(0.1)) post
eststo m25
coefplot m16 m21 m17 m22 m18 m23 m19 m24 m20 m25
 



*/by groupings
gen dummy1=0
gen dummy2=0
gen dummy3=0
gen dummy4=0

replace dummy1 = 1 if Contract ==1 
replace dummy2 = 1 if iorgact > 6
replace dummy3 = 1 if eduyrs2 > 15
replace dummy4 = 1 if dummy1 ==1 & dummy2 ==0 & dummy2 ==3 | dummy2==1 & dummy3==0 & dummy1 ==0 | dummy3==1 & dummy2==0 & dummy1 ==0
replace dummy4 = 2 if dummy1 ==1 & dummy2 ==1 | dummy2==1& dummy3==1 | dummy1==1 & dummy3==1 | dummy1==1 & dummy2==1 & dummy3==1

gen automationdum =.
replace automationdum = 0 if computerisation <=.33
replace automationdum = 1 if computerisation >.33
replace automationdum = 2 if computerisation >=.

gen archetype=.
replace archetype = 1 if dummy4 == 1 & automationdum == 1
replace archetype = 2 if dummy4 == 1 & automationdum == 0
replace archetype = 3 if dummy4 == 0 & automationdum == 1
replace archetype = 4 if dummy4 == 0 & automationdum == 0

label define archetype  1 "LR/HP" 2 "LR/LP" 3 "HR/HP" 4 "HR/LP" 
label value archetype archetype

eststo:  logistic incumbent i.automationdum##i.dummy4 eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 & country == 2 [pw=dweight], vce(robust)
margins automationdum, atmeans at(dummy4=(0)) saving(low, replace)
margins automationdum, atmeans at(dummy4=(1)) saving(med, replace)
margins automationdum, atmeans at(dummy4=(2)) saving(high, replace)


eststo:  logistic incumbent c.computerisation##i.dummy4 eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)

margins, atmeans at(dummy4=(0(1)2) computerisation=(0.9))


combomarginsplot high med low

**************************************************
**************************************************
*******************4. Robustness******************
**************************************************
**************************************************
eststo clear 
*/ Occupational dummies
 	gen occupdum=.
    replace occupdum=1 if substr(string(isco08), 1, 1) == "1"
    replace occupdum=2 if substr(string(isco08), 1, 1) == "2"
    replace occupdum=3 if substr(string(isco08), 1, 1) == "3"
    replace occupdum=4 if substr(string(isco08), 1, 1) == "4"
    replace occupdum=5 if substr(string(isco08), 1, 1) == "5"
    replace occupdum=6 if substr(string(isco08), 1, 1) == "6"
    replace occupdum=7 if substr(string(isco08), 1, 1) == "7"
	replace occupdum=8 if substr(string(isco08), 1, 1) == "8"
	replace occupdum=9 if substr(string(isco08), 1, 1) == "9"

	
	
eststo: qui asdoc logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum i.occupdum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest replace 

eststo: qui asdoc logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum i.sector  i.region if mainsample ==1 [pw=dweight], vce(robust) nest append 



*/4.1 Social background parents and attitude to migration
eststo: qui asdoc logistic incumbent c.computerisation imbgeco eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) nest append 
eststo: qui asdoc logistic incumbent c.computerisation occf14b eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum i.region if  mainsample ==1 [pw=dweight], vce(robust) nest append 

*/4.3 Fiscal policy
eststo: qui asdoc logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  deficit4 i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest append 
eststo: qui asdoc logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  difdebt4 i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust) nest append 

*/4.4 Different IV 
eststo: qui asdoc logistic incumbent c.sh_highrisk  eduyrs2 income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) nest append 
eststo: qui asdoc logistic incumbent c.rti2  eduyrs2 income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) nest append 

*/4.5 Only western Europe
eststo: qui asdoc logistic  incumbent computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1& west ==1 [pw=dweight], vce(robust) nest append 


*/4.6 Offshoreability
eststo: qui asdoc logistic  incumbent computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr offshwalt  i.year i.electiondum i.region if  mainsample ==1 [pw=dweight], vce(robust) nest append 

asdoc replay, nest

esttab est5 est6 est1 est2 est3 est4 est6 est7 est8 est9, drop(*region *electiondum *year eduyrs2 income2 age 1.male 1.urban rlgdgr) replace se  s(year electiondum region n, label("Wave FE" "Election FE" "Region FE" "N" ))


*/4.7 Additional test interacting alternative IVs with labour market resources

eststo clear 
eststo qui: logistic incumbent c.rti2##i.Contract  eduyrs2 income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) 
eststo qui: logistic incumbent c.rti2##c.iorgact  eduyrs2 income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) 
eststo qui: logistic incumbent c.rti2##c.eduyrs2  income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) 
eststo qui: logistic incumbent c.sh_highrisk##i.Contract   income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) 
eststo qui: logistic incumbent c.sh_highrisk##c.iorgact  eduyrs2 income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) 
eststo qui: logistic incumbent c.sh_highrisk##c.eduyrs2   income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1  [pw=dweight], vce(robust) 
  esttab est1 est2 es3 est4 est5 est6,  recent

*/4.8 Observable implications in attitudes
eststo clear 
 eststo: qui ologit stfgov  c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.region if mainsample ==1 & year > 2010 [pw=dweight], vce(robust)
 eststo: qui ologit jbscr  c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr i.year i.region if mainsample ==1 & year >=2010 [pw=dweight], vce(robust)
 coefplot est1 est2, keep(computerisation) xline(0)
  

*/4.9 substantial difference anti-incumbent and pro far-right vote
*/ I test this difference by defining a sample that is progressively less likely to demonstrate a difference between anti-incumbency and far-right voting
eststo: qui asdoc logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)  nest replace 
eststo: qui asdoc logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr   i.year i.electiondum i.region if  mainsample ==1 & rightpres ==1  [pw=dweight], vce(robust) nest append
eststo: qui asdoc logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum i.region if  mainsample ==1 & rightpres ==1 & rright == 0 [pw=dweight], vce(robust) nest append

esttab est2 est5 est6, drop(*region *electiondum *year) replace se  s(year electiondum region n, label("Wave FE" "Election FE" "Region FE" "N" ))

**************************************************
**************************************************
**************5. Model Diagnostics ***************
**************************************************
**************************************************
*/baseline is tested here

*/1.1. Model Specification: linktest
qui logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)
linktest
* hat is highly significant and hatsq isn't, so the model is well specified

*/1.2. Goodness of fit: fitstat
qui logistic incumbent c.computerisation i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)
quietly fitstat, save
eststo: qui logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1 [pw=dweight], vce(robust)
fitstat, diff force
* more complex model is warranted over parsimonious one

*/1.3 Multicollinearity: collin
collin computerisation eduyrs2 income2 age male urban rlgdgr electiondum year region 
* Low VIF indicates limited risk of collinearity

*/1.4 Outliers: hat (based on Pregibon)
eststo: qui logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1, vce(robust)
gen id=_n
predict hat, hat 
scatter hat id, mlab(id)
sort id
drop in 162142
eststo: qui logistic incumbent c.computerisation eduyrs2 income2 age 1.male 1.urban rlgdgr  i.year i.electiondum  i.region if mainsample ==1, vce(robust)
* Single outlier with significant leverage, but does not ultimately influence results significantly


**************************************************
**************************************************
*******************6. Final graphs ***************
**************************************************
**************************************************
*/ using plottig Scheme Dan Bischof

*/1 
hist computerisation

*/2
hist computerisation || qfit computerisation computerisation, by(country)

*/3 

		gen isco08ns=.
	*/non-routine
	replace isco08ns=1 if substr(string(isco08), 1, 2) == "11"
    replace isco08ns=2 if substr(string(isco08), 1, 2) == "12"
    replace isco08ns=3 if substr(string(isco08), 1, 2) == "13"
	replace isco08ns=4 if substr(string(isco08), 1, 2) == "14"
    replace isco08ns=5 if substr(string(isco08), 1, 2) == "21"
    replace isco08ns=6 if substr(string(isco08), 1, 2) == "22"
    replace isco08ns=7 if substr(string(isco08), 1, 2) == "23"
    replace isco08ns=8 if substr(string(isco08), 1, 2) == "24"
	replace isco08ns=9 if substr(string(isco08), 1, 2) == "25"
	replace isco08ns=10 if substr(string(isco08), 1, 2) == "26"
    replace isco08ns=11 if substr(string(isco08), 1, 2) == "31"
    replace isco08ns=12 if substr(string(isco08), 1, 2) == "32"
	replace isco08ns=13 if substr(string(isco08), 1, 2) == "33"
	replace isco08ns=14 if substr(string(isco08), 1, 2) == "34"
	replace isco08ns=15 if substr(string(isco08), 1, 2) == "35"
	replace isco08ns=16 if substr(string(isco08), 1, 2) == "41"
	replace isco08ns=17 if substr(string(isco08), 1, 2) == "42"
	replace isco08ns=18 if substr(string(isco08), 1, 2) == "43"
	replace isco08ns=19 if substr(string(isco08), 1, 2) == "44"
	replace isco08ns=20 if substr(string(isco08), 1, 2) == "51"
	replace isco08ns=21 if substr(string(isco08), 1, 2) == "52"
	replace isco08ns=22 if substr(string(isco08), 1, 2) == "53"
	replace isco08ns=23 if substr(string(isco08), 1, 2) == "54"
    replace isco08ns=24 if substr(string(isco08), 1, 2) == "61"
    replace isco08ns=25 if substr(string(isco08), 1, 2) == "62"
    replace isco08ns=27 if substr(string(isco08), 1, 2) == "71"
    replace isco08ns=28 if substr(string(isco08), 1, 2) == "72"
    replace isco08ns=29 if substr(string(isco08), 1, 2) == "73"
    replace isco08ns=30 if substr(string(isco08), 1, 2) == "74"
    replace isco08ns=31 if substr(string(isco08), 1, 2) == "75"
    replace isco08ns=32 if substr(string(isco08), 1, 2) == "81"
    replace isco08ns=33 if substr(string(isco08), 1, 2) == "82"
    replace isco08ns=34 if substr(string(isco08), 1, 2) == "83"
    replace isco08ns=35 if substr(string(isco08), 1, 2) == "91"
    replace isco08ns=36 if substr(string(isco08), 1, 2) == "92"
    replace isco08ns=37 if substr(string(isco08), 1, 2) == "93"
    replace isco08ns=38 if substr(string(isco08), 1, 2) == "94"
    replace isco08ns=39 if substr(string(isco08), 1, 2) == "95"
    replace isco08ns=40 if substr(string(isco08), 1, 2) == "96"



label define isco08ns 1 "Chief Executives and Senior Officials" 2 "Administrative and commercial Managers" 3 "Production and Specialized Services Managers"  4 "Hospitality, Retail and Other Managers" 5 "Science and Engineering Porfessionals" 6 "Health Professionals" 7 "Teaching Professionals" 8 "Business and Administration Professionals"  9 "Information and Communication Professionals" 10 "Legal, Social and Cultural Professionals" 11 "Science and Engineering Associate Porfessionals" 12 "Health Associate Professionals"  13 "Business and Administration Associate Professionals" 14 "Legal, Social and Cultural Associate Professionals" 15 "Information and Communication Technicians" 16 "General and Keyboard Clerks" 17 "Costumer Service Clerks" 18 "Numerical and Material Recording Clerks" 19 "Other Clerical Support Workers" 20 "Personal Services Workers" 21 "Sales Workers" 22 "Personal Care Workers" 23 "Protective Services Workers" 24 "Skilled Agricultural Workers" 25 "Skilled Forestry, Fishery and Hunting Workers"  27 "Building and Related Trades Workers" 28 "Metal, Machinery and Related Trades Workers" 29 "Handicraft and Printing Workers" 30 "Electrical and Electronic Trades Workers" 31 "Food Processing, Wood Working, and Other Craft and Trades" 32 "Stationary Plant and Machine Operators" 33 "Assemblers" 34 "Drivers and Mobile Plant Operators" 35 "Cleaners and Helpers" 36 "Agricultural, Forestry and Fishery Labourers" 37"Labourers in Mining, Construction, Manufacturing and Transport" 38 "Food Preparation Assistants" 39 "Street and Related Sales and Services Workers" 40 "Refuse Workers and other Elementary Workers"

 label value isco08ns isco08ns
 
 
 gen comp2 = computerisation-0.5
 
 graph bar comp2, over(isco08ns, sort(computerisation))
 
 		gen isco08ns4 =.
	*/non-routine
	replace isco08ns4=1 if substr(string(isco08), 1, 3) == "741"
    replace isco08ns4=2 if 	isco08 == 9216
    replace isco08ns4=3 if isco08 == 9311
    replace isco08ns4=4 if isco08 == 9112
    replace isco08ns4=5 if isco08 == 8832
    replace isco08ns4=6 if isco08 == 8160
    replace isco08ns4=7 if isco08 == 7112
	replace isco08ns4=8 if isco08 == 7142
    replace isco08ns4=9 if isco08 == 7115
    replace isco08ns4=10 if substr(string(isco08), 1, 2) == "61"
	replace isco08ns4=11 if isco08 == 3355
	replace isco08ns4=12 if isco08 == 5411
	replace isco08ns4=13 if isco08 == 9611
	replace isco08ns4=14 if isco08 == 5311
	replace isco08ns4=15 if isco08 == 5230
	replace isco08ns4=16 if isco08 == 5221
	replace isco08ns4=17 if isco08 == 5165
	replace isco08ns4=18 if isco08 == 5120
	replace isco08ns4=19 if isco08 == 5141
	replace isco08ns4=20 if isco08 == 5141
	replace isco08ns4=21 if isco08 == 4311
    replace isco08ns4=22 if isco08 == 4211
	replace isco08ns4=23 if isco08 == 4110
    replace isco08ns4=24 if isco08 == 3431
    replace isco08ns4=25 if isco08 == 3412
    replace isco08ns4=26 if isco08 == 3341
    replace isco08ns4=27 if isco08 == 2411
    replace isco08ns4=28 if isco08 == 3135
	replace isco08ns4=29 if isco08 == 2653
    replace isco08ns4=30 if isco08 == 2642
    replace isco08ns4=31 if isco08 == 2636
    replace isco08ns4=32 if isco08 == 2611
    replace isco08ns4=33 if isco08 == 2512
    replace isco08ns4=34 if isco08 == 2413
    replace isco08ns4=35 if isco08 == 2310
    replace isco08ns4=36 if isco08 == 2221
    replace isco08ns4=37 if isco08 == 2341
    replace isco08ns4=38 if isco08 == 4224
    replace isco08ns4=39 if isco08 == 2341
    replace isco08ns4=40 if isco08 == 3333
    replace isco08ns4=41 if isco08 == 3334
    replace isco08ns4=42 if isco08 == 5153
    replace isco08ns4=43 if isco08 == 7126
    replace isco08ns4=44 if isco08 == 1221
    replace isco08ns4=45 if isco08 == 2142


label define isco08ns4 1 "Electrician"  2 "Fisherman" 3 "Miner"  4 "Cleaner" 5 "Lorry driver" 6 "Food and related product machine operator" 7 "Bricklayer" 8 "Plasterer"  9 "Carpenter" 10 "Farmer"  11 "Police inspector" 12 "Firefighter" 13 "Garbage collector" 14 "Child-care worker" 15 "Cashier" 16 "Shopkeeper" 17 "Driving instructor" 18 "Cook" 19 "Hairdresser" 20 "Mail carrier" 21 "Accouting & bookkeeping clerks" 22 "Bank teller" 23 "General office clerks" 24 "Photographer" 25 "Social worker" 26 "Office supervisor" 27 "Accountant" 28 "Metal product process controllor" 29 "Dancer or choreographers" 30 "Journalist" 31 " Religious professional" 32 "Lawyer" 33 "Software developper" 34 "Financial analyst" 35 "University teacher" 36  "Nurse" 37 "Primary school teacher" 38 "Hotel receptionist" 39 "Insurance representative" 40 "Employment agent" 41 "Real estate agent" 42 "Building caretaker" 43 "Plumber" 44 "Sales manager" 45 "Civil engineer"
 label value isco08ns4 isco08ns4
collapse (mean) computerisation natincome2010 incumbent [w= dweight] , by(isco08ns4)

drop if isco08ns4 == 3
 
use "Final.dta", replace


collapse (mean) computerisation natincome2010 incumbent stfjb pdaprp  lkuemp ipjbhin ipjbscr iprspot jbscr oprtad stfjbot income2 [w= dweight] , by(isco08)
drop if incumbent > 0.5
scatter incumbent computerisation || lfit incumbent computerisation
 twoway ( scatter pdaprp computerisation, yaxis(2) )   ||  (scatter stfjbot computerisation, yaxis(1) )   || (scatter stfjb computerisation,  yaxis(1)) 

 
 	gen occupdum=.
    replace occupdum=1 if substr(string(isco08), 1, 1) == "1"
    replace occupdum=2 if substr(string(isco08), 1, 1) == "2"
    replace occupdum=3 if substr(string(isco08), 1, 1) == "3"
    replace occupdum=4 if substr(string(isco08), 1, 1) == "4"
    replace occupdum=5 if substr(string(isco08), 1, 1) == "5"
    replace occupdum=6 if substr(string(isco08), 1, 1) == "6"
    replace occupdum=7 if substr(string(isco08), 1, 1) == "7"
	replace occupdum=8 if substr(string(isco08), 1, 1) == "8"
	replace occupdum=9 if substr(string(isco08), 1, 1) == "9"
	
	
	

	
	



